<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>订单成功</title>
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="fonts/glyphicons-halflings-regular.woff2">
</head>
<div id="top"></div>
<body>
<div class="container" style="margin-top: 5%">
    <div class="row">
        <div class="">
            <div class="panel panel-default"  style="margin: 0 auto;width: 95%;">
                <div class="panel-heading">
                    <h3 class="panel-title"><span class="glyphicon glyphicon-yen"></span>&nbsp;&nbsp;在线支付
                        <span class="pull-right"><a href="javascript:void(0)" onclick="window.history.back()">返回订单列表</a>
				    	</span>
                    </h3>
                </div>
                <div class="panel-body">
                        <table class="table table-bordered table-striped table-hover">
                            <tr>
                                <td colspan="1">订单号:</td>
                                <td colspan="3"><label>
                                    <input id="oId" type="text" class="form-control" readonly="readonly">
                                </label></td>
                            </tr>
                            <tr>
                                <td colspan="1">支付金额:</td>
                                <td colspan="3">
                                    <div class="input-group" style="width: 200px;">
                                        <label>
                                            <input id="payCount" type="text" class="form-control" readonly>
                                        </label>
                                        <div class="input-group-addon"><span class="glyphicon glyphicon-yen"></span></div>
                                    </div>
                                </td>
                            </tr>

                        </table>
                        <div class="pull-right" style="margin-right: 30px;">
                            <button id="confirm" type="button" class="btn btn-warning btn-sm">确认支付</button>
                        </div>
                </div>
            </div>
        </div>

    </div>

</div>


<script type="text/javascript" src="js/jquery-3.6.4.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#top").load("top.html")
        //接收传过来的oId 并发送ajax请求
        const searchParams = new URLSearchParams(location.search);
        const oId = searchParams.get("oId");
        const totalCount=searchParams.get("totalCount")
        $("#oId").val(oId)
        $("#payCount").val(totalCount)
        //微信支付点击事件
        $("#confirm").click(function (){
            $.ajax({
                url:"/PDD/user?method=modifyBalance",
                data:{
                    "totalCount":totalCount,
                    "oId":oId
                },
                dataType: "json",
                success:function (data){
                    if(data.code===-1){
                        alert(data.data)
                    }else{
                        alert("支付成功")
                        //window.history.back()
                        window.history.go(-2)
                    }
                },
                error: function (jqXHR) {
                    alert("失败" + jqXHR.responseText); // 输出响应内容
                }
            })
        })
    })

</script>

</body>
</html>